home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmurl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  5.5 KB  |  197 lines

  1. #ifndef H_RPMURL
  2. #define H_RPMURL
  3.  
  4. /** \ingroup rpmio
  5.  * \file rpmio/rpmurl.h
  6.  */
  7.  
  8. #include <assert.h>
  9.  
  10. /**
  11.  * Supported URL types.
  12.  */
  13. typedef enum urltype_e {
  14.     URL_IS_UNKNOWN    = 0,    /*!< unknown (aka a file) */
  15.     URL_IS_DASH        = 1,    /*!< stdin/stdout */
  16.     URL_IS_PATH        = 2,    /*!< file://... */
  17.     URL_IS_FTP        = 3,    /*!< ftp://... */
  18.     URL_IS_HTTP        = 4,    /*!< http://... */
  19.     URL_IS_HTTPS    = 5,    /*!< https://... */
  20.     URL_IS_HKP        = 6    /*!< hkp://... */
  21. } urltype;
  22.  
  23. #define    URLMAGIC    0xd00b1ed0
  24. #define    URLSANE(u)    assert(u && u->magic == URLMAGIC)
  25.  
  26. typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo;
  27.  
  28. /**
  29.  * URL control structure.
  30.  */
  31. struct urlinfo_s {
  32. /*@refs@*/ int nrefs;        /*!< no. of references */
  33. /*@owned@*/ /*@relnull@*/
  34.     const char * url;        /*!< copy of original url */
  35. /*@owned@*/ /*@relnull@*/
  36.     const char * scheme;    /*!< URI scheme. */
  37. /*@owned@*/ /*@null@*/
  38.     const char * user;        /*!< URI user. */
  39. /*@owned@*/ /*@null@*/
  40.     const char * password;    /*!< URI password. */
  41. /*@owned@*/ /*@relnull@*/
  42.     const char * host;        /*!< URI host. */
  43. /*@owned@*/ /*@null@*/
  44.     const char * portstr;    /*!< URI port string. */
  45. /*@owned@*/ /*@null@*/
  46.     const char * proxyu;    /*!< FTP: proxy user */
  47. /*@owned@*/ /*@null@*/
  48.     const char * proxyh;    /*!< FTP/HTTP: proxy host */
  49.     int proxyp;            /*!< FTP/HTTP: proxy port */
  50.     int    port;            /*!< URI port. */
  51.     int urltype;        /*!< URI type. */
  52.     FD_t ctrl;            /*!< control channel */
  53.     FD_t data;            /*!< per-xfer data channel */
  54.  
  55. /*@relnull@*/
  56.     void * capabilities;    /*!< neon: ne_server_capabilities ptr */
  57. /*@relnull@*/
  58.     void * lockstore;        /*!< neon: ne_lock_store ptr */
  59. /*@relnull@*/
  60.     void * sess;        /*!< neon: ne_session ptr */
  61.     off_t current;        /*!< neon: current body offset. */
  62.     off_t total;        /*!< neon: total body length. */
  63.     int connstatus;        /*!< neon: connection status. */
  64. #ifdef  REFERENCE
  65. typedef enum {
  66.     ne_conn_namelookup,    /* lookup up hostname (info = hostname) */
  67.     ne_conn_connecting,    /* connecting to host (info = hostname) */
  68.     ne_conn_connected,    /* connected to host (info = hostname) */
  69.     ne_conn_secure    /* connection now secure (info = crypto level) */
  70. } ne_conn_status;
  71. #endif
  72.  
  73.     int bufAlloced;        /*!< sizeof I/O buffer */
  74. /*@owned@*/
  75.     char * buf;            /*!< I/O buffer */
  76.     int openError;        /*!< Type of open failure */
  77.     int httpVersion;
  78.     int httpHasRange;
  79.     int magic;
  80. };
  81.  
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85.  
  86. /*@unchecked@*/
  87. extern int _url_count;        /*!< No. of cached URL's. */
  88.  
  89. /*@unchecked@*/
  90. /*@only@*/ /*@null@*/
  91. extern urlinfo * _url_cache;    /*!< URL cache. */
  92.  
  93. /*@unchecked@*/
  94. extern int _url_iobuf_size;    /*!< Initial size of URL I/O buffer. */
  95. #define RPMURL_IOBUF_SIZE    4096
  96.  
  97. /*@unchecked@*/
  98. extern int _url_debug;        /*!< URL debugging? */
  99. #define RPMURL_DEBUG_IO        0x40000000
  100. #define RPMURL_DEBUG_REFS    0x20000000
  101.  
  102.  
  103. /**
  104.  * Create a URL control structure instance.
  105.  * @param msg        debugging identifier (unused)
  106.  * @return        new instance
  107.  */
  108. /*@unused@*/ urlinfo    urlNew(const char * msg)    /*@*/;
  109.  
  110. /** @todo Remove debugging entry from the ABI. */
  111. urlinfo    XurlNew(const char * msg, const char * file, unsigned line)    /*@*/;
  112. #define    urlNew(_msg) XurlNew(_msg, __FILE__, __LINE__)
  113.  
  114. /**
  115.  * Reference a URL control structure instance.
  116.  * @param u        URL control structure
  117.  * @param msg        debugging identifier (unused)
  118.  * @return        referenced instance
  119.  */
  120. /*@unused@*/ urlinfo    urlLink(urlinfo u, const char * msg)
  121.     /*@modifies u @*/;
  122.  
  123. /** @todo Remove debugging entry from the ABI. */
  124. urlinfo    XurlLink(urlinfo u, const char * msg, const char * file, unsigned line)
  125.     /*@modifies u @*/;
  126. #define    urlLink(_u, _msg) XurlLink(_u, _msg, __FILE__, __LINE__)
  127.  
  128. /**
  129.  * Dereference a URL control structure instance.
  130.  * @param u        URL control structure
  131.  * @param msg        debugging identifier (unused)
  132.  * @return        dereferenced instance (NULL if freed)
  133.  */
  134. /*@unused@*/ urlinfo    urlFree( /*@killref@*/ urlinfo u, const char * msg)
  135.     /*@globals fileSystem, internalState @*/
  136.     /*@modifies u, fileSystem, internalState @*/;
  137.  
  138. /** @todo Remove debugging entry from the ABI. */
  139. urlinfo    XurlFree( /*@killref@*/ urlinfo u, const char * msg,
  140.         const char * file, unsigned line)
  141.     /*@globals fileSystem, internalState @*/
  142.     /*@modifies u, fileSystem, internalState @*/;
  143. #define    urlFree(_u, _msg) XurlFree(_u, _msg, __FILE__, __LINE__)
  144.  
  145. /**
  146.  * Free cached URL control structures.
  147.  */
  148. void urlFreeCache(void)
  149.     /*@globals _url_cache, _url_count, fileSystem, internalState @*/
  150.     /*@modifies _url_cache, _url_count, fileSystem, internalState @*/;
  151.  
  152. /**
  153.  * Return type of URL.
  154.  * @param url        url string
  155.  * @return        type of url
  156.  */
  157. urltype    urlIsURL(const char * url)
  158.     /*@*/;
  159.  
  160. /**
  161.  * Return path component of URL.
  162.  * @param url        url string
  163.  * @retval pathp    pointer to path component of url
  164.  * @return        type of url
  165.  */
  166. /*@-incondefs@*/
  167. urltype    urlPath(const char * url, /*@out@*/ const char ** pathp)
  168.     /*@ensures maxSet(*pathp) == 0 /\ maxRead(*pathp) == 0 @*/
  169.     /*@modifies *pathp @*/;
  170. /*@=incondefs@*/
  171.  
  172. /**
  173.  * Parse URL string into a control structure.
  174.  * @param url        url string
  175.  * @retval uret        address of new control instance pointer
  176.  * @return        0 on success, -1 on error
  177.  */
  178. int urlSplit(const char * url, /*@out@*/ urlinfo * uret)
  179.     /*@globals h_errno, internalState @*/
  180.     /*@modifies *uret, internalState @*/;
  181.  
  182. /**
  183.  * Copy data from URL to local file.
  184.  * @param url        url string of source
  185.  * @param dest        file name of destination
  186.  * @return        0 on success, otherwise FTPERR_* code
  187.  */
  188. int urlGetFile(const char * url, /*@null@*/ const char * dest)
  189.     /*@globals h_errno, fileSystem, internalState @*/
  190.     /*@modifies fileSystem, internalState @*/;
  191.  
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195.  
  196. #endif    /* H_RPMURL */
  197.